﻿class com.dinmax.flash.utilities.xml.XMLUtils {
	
	public static function getNodes(node:XMLNode, name:String):Array {
		var a:Array = new Array();
		if (node.hasChildNodes()) {
			// use firstChild to iterate through the child nodes of rootNode
			for (var aNode:XMLNode = node.firstChild; aNode != null; aNode=aNode.nextSibling) {
				if (aNode.nodeType == 1 && aNode.nodeName==name) {
					a.push(aNode);
				}
			}
			
		};
		return a;	
	};
	
	public static function getNode(node:XMLNode, name:String):XMLNode {
		if (node.hasChildNodes()) {
			// use firstChild to iterate through the child nodes of rootNode
			for (var aNode:XMLNode = node.firstChild; aNode != null; aNode=aNode.nextSibling) {
				if (aNode.nodeType == 1 && aNode.nodeName==name) {
					return aNode;
				}
			}
			//throw new Error("XMLUtils.as | ERROR | No se encuentra el nodo= '"+name+"'");
			return undefined;
		};
	};

	public static function getAttribute(node:XMLNode, attribute:String):String {
		for(var sNested:String in node.attributes){
			if (sNested == attribute){
			return String(node.attributes[sNested]);
			};
		}
		//throw new Error("XMLUtils.as | ERROR | No se encuentra el atributo= '"+attribute+"'");
		return undefined;
	};

}; // fin de clase